package com.cjp.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cjp.mapper.UserMapper;
import com.cjp.pojo.User;
import com.cjp.service.IUserService;
import com.cjp.utils.Md5Util;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
@RequiredArgsConstructor
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService{

    private final UserMapper userMapper;

    @Override
    public void register(String username, String password) {
        // 密码要使用 md5 加密
        String md5Password = Md5Util.getMD5String(password);

        User user = User.builder()
                .username(username)
                .password(md5Password)
                .createTime(LocalDateTime.now())
                .updateTime(LocalDateTime.now())
                .build();
        userMapper.insert(user);
    }

}
